import req from '@/utils/request.js';
import * as URL from '@/constants/api.js';

// 密码登录
export function passwordLogin(params) {
  return req({
    url: URL.PASSWORDLOGIN,
    method: 'post',
    data: params,
  })
    .then((res) => {
      return res.data;
    })
    .catch((err) => Promise.reject(err.response.data));
}
// 验证码登录
export function phoneLogin(params) {
  return req({
    url: URL.PHONELOGIN,
    method: 'post',
    data: params,
  })
    .then((res) => res.data)
    .catch((err) => Promise.reject(err.response.data.message));
}
// 获取验证码
export function getPhoneCode(params) {
  return req({
    url: URL.LOGIN_CODE,
    params,
  })
    .then((res) => res)
    .catch((err) => Promise.reject(err.response.data.message));
}
// 获取用户信息
export function getUserInfo(params) {
  return req({
    url: URL.USER_INFO,
    params,
  })
    .then((res) => res.data)
    .catch((err) => Promise.reject(err.response.data.message));
}
// info
export function getInfo(params) {
  return req({
    url: URL.INFO,
    params,
  })
  .then((res) => res.data)
  .catch((err) => Promise.reject(err.response.data.message));
}
